<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>频率限制配置表</title>
    <script type="text/javascript" src="../../scripts/easyui1.7.0/jquery.min.js"></script>
    <script type="text/javascript" src="../../scripts/easyui1.7.0/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="../../scripts/easyui1.7.0/easyui.comm.valid.js"></script>
    <script type="text/javascript" src="../../scripts/easyui1.7.0/locale/easyui-lang-zh_CN.js"></script>
    <script type="text/javascript" src="../../scripts/easyui.grid.hide.js"></script>
    <script type="text/javascript" src="../../scripts/Common.js"></script>
    <script type="text/javascript" src="../../scripts/comm.dict.js"></script>
    <script type="text/javascript" src="../../scripts/DateUtils.js"></script>
    <link rel="stylesheet" type="text/css" href="../../scripts/easyui1.7.0/themes/bootstrap/easyui.css">
    <link rel="stylesheet" type="text/css" href="../../scripts/easyui1.7.0/themes/icon.css">

    <style type="text/css">
        #fm {
            margin: 0;
            padding: 10px 20px;
        }

        .ftitle {
            font-size: 14px;
            font-weight: bold;
            padding: 5px 0;
            margin-bottom: 10px;
            border-bottom: 1px solid #ccc;
        }

        .fitem {
            margin-bottom: 5px;
        }

        .fitem label {
            display: inline-block;
            width: 60px;
        }

        .input_query {
            width: 80px;
        }

        input, textarea {
            width: 250px;
            border: 1px solid #ccc;
            padding: 2px;
        }
    </style>
</head>

<body>

<div class="easyui-layout" data-options="fit:true">
    <!-- 查询条件  -->
    <div data-options="region:'north', title:'频率限制配置表-条件'"
         style="height: 80px; padding: 5px 80px;display:none;">
        <form id="search-form">
            <table class="search-table">
                <tr>
                    <td>
                        <input type="text" id="query_uri" name="uri" class="easyui-validatebox" placeholder="Input uri">
                    </td>

                    <td>
                        <a class="easyui-linkbutton"
                           data-options="iconCls:'icon-search'" id="search-btn">查询</a>
                    </td>
                </tr>
            </table>
        </form>
    </div>

    <!-- 查询结果 center -->
    <div data-options="region:'center'">
        <table id="dg" class="easyui-datagrid"
               data-options="fit:true, onDblClickRow:onDblClick,queryParams:function(){return $('#search-form').serializeJson();}, onClickRow:onClick, onLoadError:loadError, onLoadSuccess:function(){$('.datagrid-btable').find('div.datagrid-cell').css('text-align','left');}"
                pagination="true"
               rownumbers="true" fitColumns="true" singleSelect="true" style="display:none;">
            <thead>
            <tr>
                <th align="center" field="uri" width="100" sortable="true">uri</th>
                <th align="center" field="uriId" width="50" sortable="true" hidden="true">uriId</th>
                <th align="center" field="code" width="50" sortable="true">编码</th>
                <th align="center" field="cout" width="50" sortable="true">数量</th>
                <th align="center" field="maxCreateTime" width="50" sortable="true" formatter="timestampFormatDateTime">最大创建时间</th>
                <th align="center" field="maxModifyTime" width="50" sortable="true" formatter="timestampFormatDateTime">最大修改时间</th>
            </tr>
            </thead>
        </table>
    </div>
</div>

<div id="dlg" class="easyui-dialog" style="width:450px;height:500px;padding:5px 10px;display:none;"
     closed="true" buttons="#dlg-buttons">
    <form id="fm" method="post" novalidate>

        <div class="fitem">
            <label>uri:</label>
            <input name="uri" class="easyui-validatebox" required="false" readonly="true" disabled="true">
        </div>

        <div class="fitem">
            <label>编码:</label>
            <input name="code" class="easyui-validatebox" required="true" readonly="true" disabled="true">
        </div>
        <div class="fitem">
            <label>数量:</label>
            <input name="cout" class="easyui-validatebox">
        </div>
        <div class="fitem">
            <label>异常消息:</label>
            <input name="errMsg" class="easyui-validatebox" >
        </div>
    </form>
    <div id="dlg-buttons">
        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-ok" onclick="onSave()">Save</a>
        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-cancel"
           onclick="javascript:$('#dlg').dialog('close')">Cancel</a>
    </div>
</div>

<script type="text/javascript">
    $('#search-btn').click(function () {
        doSearch();
    });
    $('#reset-btn').click(function () {
        $('#search-form')[0].reset();
    });

    $(function () {
        doSearch();
    });


    function doSearch() {
        var  url="/dflcore/dflFrequency/listUriConfigCounts";
        var jsonParam = $('#search-form').serializeJson();
        $('#dg').datagrid({headers:app.headers, url: url, queryParams: jsonParam})
    }


    function doSearchReload() {
        var jsonParam = $('#search-form').serializeJson();
        $('#dg').datagrid('reload', jsonParam);
    }

    function onDblClick(rowIndex, rowData) {
        //alert('---onDblClick--rowIndex='+rowIndex+' row.id='+rowData.id);
        onEdit();
    }

    function onClick(rowIndex, rowData) {

    }

    function listenerName(ex) {
        if (ex.keyCode == 13) {
            doSearch();
        }
    }

    $('#query_code').keydown(listenerName);
    $('#query_name').keydown(listenerName);

    var url;

    function onAdd() {
        $('#dlg').dialog('open').dialog('setTitle', 'New DflFrequency');
        $('#fm').form('clear');
        $('#dflFrequency_freqLimitType').combobox("enable");
        $('#dflFrequency_status').combobox('select', '1');
        //$("#dflFrequency_remark").val('test');
    }


    function getRowData(entityName, row) {
        var tmp;
        var obj = {}
        obj[entityName] = {};
        for (i in row) {
            tmp = row[i];
            obj[i] = tmp;
        }
        return obj;
    }

    function onEdit() {
        var row = $('#dg').datagrid('getSelected');
        if (row) {
            var entityName = 'dflFrequency';
            $('#fm').form('clear');
            var obj = getRowData(entityName, row);
            $('#dflFrequency_freqLimitType').combobox("disable");
            $('#dlg').dialog('open').dialog('setTitle', 'Edit DflFrequency');
            $('#fm').form('load', obj);
        }

    }

</script>
</body>
</html>